/*    */ package com.zimbra.qa.unittest.prov.soap;
/*    */ 
/*    */ import com.google.common.collect.Maps;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.soap.SoapProvisioning;
/*    */ import com.zimbra.cs.httpclient.URLUtil;
/*    */ import com.zimbra.qa.unittest.TestUtil;
/*    */ import java.io.PrintStream;
/*    */ import java.util.Map;
/*    */ import org.junit.AfterClass;
/*    */ import org.junit.Assert;
/*    */ import org.junit.BeforeClass;
/*    */ import org.junit.Test;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class TestSoapProvisioning
/*    */   extends SoapTest
/*    */ {
/*    */   private static SoapProvTestUtil provUtil;
/*    */   private static Provisioning prov;
/*    */   private static Domain domain;
/*    */   
/*    */   @BeforeClass
/*    */   public static void init()
/*    */     throws Exception
/*    */   {
/* 43 */     provUtil = new SoapProvTestUtil();
/* 44 */     prov = provUtil.getProv();
/* 45 */     domain = provUtil.createDomain(baseDomainName());
/*    */   }
/*    */   
/*    */   @AfterClass
/*    */   public static void cleanup() throws Exception {
/* 50 */     Cleanup.deleteAll(new String[] { baseDomainName() });
/*    */   }
/*    */   
/*    */   @Test
/*    */   public void isExpired() throws Exception {
/* 55 */     long lifeTimeSecs = 5L;
/*    */     
/* 57 */     String acctName = TestUtil.getAddress("isExpired", domain.getName());
/* 58 */     String password = "test123";
/* 59 */     Map<String, Object> attrs = Maps.newHashMap();
/* 60 */     attrs.put("zimbraIsAdminAccount", "TRUE");
/* 61 */     attrs.put("zimbraAdminAuthTokenLifetime", String.valueOf(lifeTimeSecs) + "s");
/* 62 */     Account acct = provUtil.createAccount(acctName, password, attrs);
/*    */     
/* 64 */     SoapProvisioning soapProv = new SoapProvisioning();
/*    */     
/* 66 */     Server server = prov.getLocalServer();
/* 67 */     soapProv.soapSetURI(URLUtil.getAdminURL(server));
/*    */     
/* 69 */     Assert.assertTrue(soapProv.isExpired());
/*    */     
/* 71 */     soapProv.soapAdminAuthenticate(acctName, password);
/*    */     
/* 73 */     Assert.assertFalse(soapProv.isExpired());
/*    */     
/* 75 */     System.out.println("Waiting for " + lifeTimeSecs + " seconds");
/* 76 */     Thread.sleep((lifeTimeSecs + 1L) * 1000L);
/*    */     
/* 78 */     Assert.assertTrue(soapProv.isExpired());
/*    */     
/* 80 */     prov.deleteAccount(acct.getId());
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/prov/soap/TestSoapProvisioning.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */